/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.ac.iie.di.ban.data.exchange.runner.master;

import cn.iie.jsqlparser.helper.JSQLParserHelper;
import java.util.List;

/**
 *
 * @author Administrator
 */
public class TopicParser {

    public static String getSrcTopicName(String sql) throws Exception {
        String srctopic = "";
        JSQLParserHelper sqlParser = new JSQLParserHelper(sql);
        List<String> sqlTables = sqlParser.getSQLTables();
        for (String sqlTable : sqlTables) {
            srctopic += sqlTable + "_";
        }
        srctopic = srctopic.substring(0, srctopic.length() - 1);
        return srctopic;
    }
}
